<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username' => 'require|unique:user|max:25',
        'password' => 'require|length:6,25'
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'username.unique' => '企业匿名码已存在',
        'username.length' => '用户名长度2-25位',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度6-25位',
    ];

    public function sceneAdd()
    {
        return $this->only(['username', 'password'])->append('username', 'require|length:2,25|token');
    }
    public function sceneEdit()
    {
        return $this->only(['username'])->append('username', 'require|length:2,25|token');
    }

}